<%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2023/11/14
  Time: 8:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>会员信息列表</title>
</head>
<body>

<table border="1">
    <tr>
        <th colspan="7">会员信息列表</th>
    </tr>
    <tr>
        <td>编号</td>
        <td>姓名</td>
        <td>性别</td>
        <td>年龄</td>
        <td>家庭住址</td>
        <td>Email</td>
        <td>操作</td>
    </tr>

</table>
</body>
<script src="static/jquery-1.8.3.min.js"></script>
<script>
    $(function () {
        findAll();
    })

    function findAll() {
        $.ajax({
            url: '/findAll',
            dataType: 'json',
            method: 'post',
            success: function (data) {
                // console.log(data)
                $('table tr:gt(1)').remove();
                data.forEach(item => {
                    $('table').append(`<tr>
        <td><a href="update.jsp?id=\${item.id}">\${item.id}</a></td>
        <td>\${item.mname}</td>
        <td>\${item.mgender}</td>
        <td>\${item.mage}</td>
        <td>\${item.maddress}</td>
        <td>\${item.memail}</td>
        <td><a href="javascript:del(\${item.id})">删除</a></td>
    </tr>`)
                })
            }
        })
    }

    function del(id) {
        if(confirm("确认删除吗？")){
            $.getJSON("/del/"+id,data=>{
                alert(data['msg'])
                findAll();
            })
        }
    }

</script>
</html>
